#include <stdio.h>
#include <stdlib.h>

#define CLUSTER_LIBRE 0x00000000
#define CLUSTER_RESERVADO 0x00000001
#define CLUSTER_RESERVADO2 0x0FFFFFF6
#define CLUSTER_CORRUPTO 0x0FFFFFF7
#define CLUSTER_OCUPADO 0x0FFFFFF8

struct boot_sector_values
	{
	unsigned char value_jump_instruction[3] ;
	unsigned char value_oem_name[8];
	unsigned short value_bytes_per_sector;
	unsigned char value_sector_per_cluster;
	unsigned short value_reserved_sector_count;
	unsigned char value_number_of_fats;
	unsigned short value_number_of_root_dirs;
	unsigned short value_total_sectors;
	unsigned char value_media_descriptor;
	unsigned short value_sectors_per_fat;
	unsigned short value_sectors_per_track;
	unsigned short value_number_of_heads;
	unsigned int value_hidden_sectors_for_partition;
	unsigned int value_total_sectors_greater;
	unsigned int value_sectors_per_fat_table;
	unsigned short value_fat_flags;
	unsigned short value_version;
	unsigned int value_cluster_number_root_start;
	unsigned short value_sector_fs_information;
	unsigned short value_sector_of_boot_copy;
	unsigned char value_reserved[12];
	unsigned char value_physical_drive_number;
	unsigned char value_reserved1;
	unsigned char value_extended_boot_signature;
	unsigned int value_id;
	unsigned char value_label[11];
	double value_fat_type;
	unsigned char value_OS_boot_code[420];
	unsigned short value_boot_sector_signature;
	}__attribute__ ((__packed__));

struct FS_information_sector_values
{
	unsigned char FS_infrmation_signature[4];
	unsigned char reserverd[480];
	unsigned char FS_infrmation_signature2[4];
	unsigned int free_clusters;
	unsigned int ultimo_cluster_acedido;
	unsigned char reserved2[12];
	unsigned char FS_infrmation_signature3[4];
} __attribute__ ((__packed__));

struct super_cacho
{
	char 			*cacho_de_memoria;
	unsigned int	cluster_inicial;
	unsigned int 	cantidad_de_clusters;
};

typedef struct super_cacho SUPER_CACHO;

unsigned int * FAT_llenar_Tabla_FAT (struct boot_sector_values, FILE *);
unsigned long FAT_largo_tabla_FAT_bytes(struct boot_sector_values);
SUPER_CACHO FAT_traer_contenido_de_directorio(char * );
